package com.darco.darcoapp;

import static DARCOShared.utils.Constants.*;
import android.content.ContentValues;
import android.widget.Toast;

import com.darco.darcoapp.db.DarcoData;

//classe per racchiudere le funzione comuni ai settings
public class Settings {

	//cambia il campo allowLocation su db e contentValues
	public static boolean setAllowLocation(DarcoData d,ContentValues s, boolean bl){
		boolean dbsaved=false;
		int b=0;
		if(bl==true) 
			b=1;
		//accesso e modifica del campo dati allowlocation nel db locale
		if(d!=null && s!=null){
			ContentValues system = d.getSystemData();
			if(system!=null){
				dbsaved=d.addSystem(system.getAsString(SYSTEM_APPCODE),
						system.getAsString(SYSTEM_SAVEDACCOUNT), 
						system.getAsInteger(SYSTEM_FIRSTSTART), b);
			}
			s.put(SYSTEM_ALLOWLOCATION, b);
		}

		return dbsaved;
	}

	public static boolean clearLocalDb(DarcoData d){
		d.deleteAll(TABLE_NAME_CARDS);
		d.deleteAll(TABLE_NAME_ACCOUNTS);
		d.deleteAll(TABLE_NAME_CATEGORIES);
		d.deleteAll(TABLE_NAME_UNIQUECARDS);
		d.deleteAll(TABLE_NAME_SECURITY);
		return true;
	}

}
